Skip to content

Add Server count metric #760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yolossn
Copy link

@yolossn yolossn commented Aug 4, 2025

this patch adds server count metric

fixes: #521

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 4, 2025
@k8s-ci-robot k8s-ci-robot requested a review from elmiko August 4, 2025 07:44
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yolossn
Once this PR has been reviewed and has the lgtm label, please assign ipochi for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested a review from tallclair August 4, 2025 07:44
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 4, 2025
this patch adds server count metric

fixes: kubernetes-sigs#521

Signed-off-by: yolossn <[email protected]>
@yolossn yolossn force-pushed the add_server_count_metric branch from 0a4a49c to b31592d Compare August 4, 2025 07:48
@@ -389,6 +389,8 @@ func NewProxyServer(serverID string, proxyStrategies []proxystrategies.ProxyStra
}
}

metrics.Metrics.SetServerCount(serverCount)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe serverCount is the value passed in from the command line. https://github.com/kubernetes-sigs/apiserver-network-proxy/blob/v0.33.0/cmd/server/app/server.go#L141 is the only place I know its set.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, do you want me to move this SetServerCount to /cmd/server/app/server.go itself?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I was more thinking that this is the API configured server count, not necessarily the actual server count. It does not actually tell you many servers are up, just how many we advertise to the agents. Even with that the agents themselves will periodically attempt to detect if there are more than advertised.

The server lease for instance (if used) has an actual count of the number of servers which are running.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah my bad, got your point now.

Since the agent already has the lease informer, should we add the server_count metric to the agent (i.e., the NewLeaseInformerWithMetrics) or create a new lease informer in the server pkg and use it in the server?"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on further investigation came across this, looks like the agent already exposes the known_server_count metric.

serverCount := prometheus.NewGauge(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prometheus metric to say how many konectivity-server are there
3 participants